{% extends 'base.html' %}

{% block title %}
    首页
{% endblock %}

{% block main %}
    <h1>博客列表</h1>

    <div class="row row-cols-2 row-gap-3">
        {% for blog in blogs %}
            <div class="col">
                <div class="card">
                    <div class="card-header">
                        <a href="{% url 'blog:blog_detail' blog_id=blog.id %}">{{ blog.title }}</a>
                    </div>
                    <div class="card-body" style="height: 120px">
                        <p class="card-text">{{ blog.content|safe|striptags|truncatechars:100 }}</p>
                    </div>
                    <div class="card-footer text-muted d-flex justify-content-between">
                        <div>
                            <img src="{% static 'image/moyu.jpg' %}" class="rounded-circle" height="35">
                            {{ blog.author.username }}
                        </div>
                        <div>
                            发布时间:{{ blog.pub_time|date:"Y年m月d日 h时i分s秒" }}
                        </div>
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endblock %}